package cn.syy.controller.app;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.syy.pojo.domain.Login;
import cn.syy.pojo.param.RegisterSaveLoginParam;
import cn.syy.pojo.query.PageQueryWrapper;
import cn.syy.pojo.vo.LoginInfoVo;
import cn.syy.result.PageResult;
import cn.syy.result.R;
import cn.syy.service.ILoginService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.List;

@Tag(name = "小程序登录表",description = "小程序登录表")
@RestController
@RequestMapping("/app/login")
public class APPLoginController {

    @Autowired
    public ILoginService loginService;

    @Operation( summary= "小程序微信登录",description = "小程序微信登录接口")
    @Parameter(name = "wxlogin",description = "保存的对象",required = true)
    @PostMapping("/wxlogin/{code}/{type}")
    @SaIgnore
    public R<LoginInfoVo> wxlogin(@PathVariable("code") @NotEmpty String code, @PathVariable("type") @NotEmpty Integer type){//  @Valid：用来验证参数的
        return R.success( loginService.wxlogin(code,type));
    }

    @Operation( summary= "小程序注册保存Login",description = "小程序注册保存Login接口")
    @Parameter(name = "login",description = "保存的对象",required = true)
    @PostMapping
    @SaIgnore
    public R<Void> save(@RequestBody @Valid RegisterSaveLoginParam registerSaveLoginParam){//  @Valid：用来验证参数的
        loginService.registerSaveLogin(registerSaveLoginParam);
        return R.success();
    }



}
